﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace MyWeb.Data
{
    public class GroupProductController : SqlDataProvider
    {
        #region[GroupProduct_Insert]
        public void GroupProduct_Insert(GroupProductInfo data)
        {
            using (SqlCommand cmd = new SqlCommand("sp_GroupProduct_Insert", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@Name", data.Name));
                cmd.Parameters.Add(new SqlParameter("@Content", data.Content));
                cmd.Parameters.Add(new SqlParameter("@Images", data.Images));
                cmd.Parameters.Add(new SqlParameter("@Order", data.Order));
                cmd.Parameters.Add(new SqlParameter("@Status", data.Status));
                cmd.ExecuteNonQuery();
            }
        }
        #endregion

        #region[GroupProduct_Update]
        public void GroupProduct_Update(GroupProductInfo data)
        {
            using (SqlCommand cmd = new SqlCommand("sp_GroupProduct_Update", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@Id", data.Id));
                cmd.Parameters.Add(new SqlParameter("@Name", data.Name));
                cmd.Parameters.Add(new SqlParameter("@Content", data.Content));
                cmd.Parameters.Add(new SqlParameter("@Images", data.Images));
                cmd.Parameters.Add(new SqlParameter("@Order", data.Order));
                cmd.Parameters.Add(new SqlParameter("@Status", data.Status));
                cmd.ExecuteNonQuery();
            }
        }
        #endregion

        #region[GroupProduct_Delete]
        public void GroupProduct_Delete(string Id)
        {
            using (SqlCommand cmd = new SqlCommand("sp_GroupProduct_Delete", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@Id", Id));
                cmd.ExecuteNonQuery();
            }
        }
        #endregion

        #region[GroupProduct_GetByAll]
        public DataTable GroupProduct_GetByAll()
        {
            using (SqlCommand cmd = new SqlCommand("sp_GroupProduct_GetByAll", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable ds = new DataTable();
                da.Fill(ds);
                return ds;
            }
        }
        #endregion

        #region[GroupProduct_GetById]
        public DataTable GroupProduct_GetById(string Id)
        {
            using (SqlCommand cmd = new SqlCommand("sp_GroupProduct_GetById", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@Id", Id));
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable ds = new DataTable();
                da.Fill(ds);
                return ds;
            }
        }
        #endregion

        #region[GroupProduct_GetByTop]
        public DataTable GroupProduct_GetByTop(string Top, string Where, string Order)
        {
            using (SqlCommand cmd = new SqlCommand("sp_GroupProduct_GetByTop", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@Top", Top));
                cmd.Parameters.Add(new SqlParameter("@Where", Where));
                cmd.Parameters.Add(new SqlParameter("@Order", Order));
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable ds = new DataTable();
                da.Fill(ds);
                return ds;
            }
        }
        #endregion
    }
}
